#include "BieuThucHang.h"

BieuThucHang* BieuThucHang::ZERO = new BieuThucHang(0);

BieuThucHang::BieuThucHang()
{
	hangSo = 0;
}

BieuThucHang::BieuThucHang(double hangSo)
{
	this->hangSo = hangSo;
}


BieuThucHang* BieuThucHang::taoBieuThucHang(double hangSo)
{
	if (hangSo == 0)
	{
		return ZERO;
	}
	else
	{
		return new BieuThucHang(hangSo);
	}
};


double BieuThucHang::tinhGiaTri(double x)
{
	return hangSo;
}

//BieuThuc* BieuThucHang::tinhDaoHam(){
//	BieuThuc* kq = new BieuThucHang();
//	return kq;
//}

BieuThuc* BieuThucHang::timDaoHam()
{
	return ZERO;	// Sua lai
}

void BieuThucHang::daoDauBieuThuc()
{
	this->hangSo = hangSo * (-1);
}

string BieuThucHang::xuatChuoi()
{
	std::ostringstream sstr;

	if(this->hangSo == 0 || this == NULL)
		return "";
	else
	{
		sstr << hangSo;
		return sstr.str();
	}
}